package pers.vic.base.bo.system;

import java.io.Serializable;
import java.math.BigDecimal;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 数据字典
 * 
 * @author VIC
 *
 */
public class SysDict implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 编码 一级 1 二级 101---199 三接1xx 001 -1xx 999 四级 同三级
	 */
	private Long code;

	/**
	 * 名称
	 */
	private String name;

	/**
	 * 业务值
	 */
	private String businessValue;

	/**
	 * 备注
	 */
	private String remark;

	/**
	 * 排序
	 */
	private Integer sort;

	/**
	 * 启用/禁用
	 */
	private Integer enabled;

	/**
	 * 是否删除
	 */
	private Integer isDelete;

	/**
	 * 父编码 一般新增的时候才用到
	 */
	@JsonIgnore
	private Long pcode;

	public String getIconSkin() {
		if (this.code > 999999999) {
			return "icon04";
		}
		if (this.code > 999999) {
			return "icon03";
		}
		if (this.code > 999) {
			return "icon02";
		}
		if (this.code >= 1) {
			return "pIcon01";
		}
		return "icon008";
	}

	/**
	 * set：编码
	 */
	public SysDict setCode(Long code) {
		this.code = code;
		return this;
	}

	/**
	 * get：编码
	 */
	public Long getCode() {
		return code;
	}

	/**
	 * set：名称
	 */
	public SysDict setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * get：名称
	 */
	public String getName() {
		return name;
	}

	/**
	 * set：备注
	 */
	public SysDict setRemark(String remark) {
		this.remark = remark;
		return this;
	}

	/**
	 * get：备注
	 */
	public String getRemark() {
		return remark;
	}

	/**
	 * set：排序
	 */
	public SysDict setSort(Integer sort) {
		this.sort = sort;
		return this;
	}

	/**
	 * get：排序
	 */
	public Integer getSort() {
		return sort;
	}

	/**
	 * set：启用/禁用
	 */
	public SysDict setEnabled(Integer enabled) {
		this.enabled = enabled;
		return this;
	}

	/**
	 * get：启用/禁用
	 */
	public Integer getEnabled() {
		return enabled;
	}

	/**
	 * set：是否删除
	 */
	public SysDict setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
		return this;
	}

	/**
	 * get：是否删除
	 */
	public Integer getIsDelete() {
		return isDelete;
	}

	public Long getPcode() {
		return pcode;
	}

	public void setPcode(Long pcode) {
		this.pcode = pcode;
	}

	/**
	 * 业务值
	 * 
	 * @return
	 */
	public String getBusinessValue() {
		return businessValue;
	}

	public void setBusinessValue(String businessValue) {
		this.businessValue = businessValue;
	}

	/**
	 * Integer 类型的业务值
	 */
	public int getBusinessValueInteger() {
		try {
			return Integer.parseInt(businessValue);
		} catch (Exception e) {
		}
		return 0;
	}

	/**
	 * BigDecimal 类型的业务值
	 */
	public BigDecimal getBusinessValueBigDecimal() {
		try {
			return new BigDecimal(businessValue);
		} catch (Exception e) {
		}
		return BigDecimal.ZERO;
	}

}
